package org.jeecg.modules.index;

import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.SecurityUtils;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.exception.JeecgBootException;
import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.common.util.DateUtils;
import org.jeecg.common.util.UUIDGenerator;
import org.jeecg.common.util.oConvertUtils;
import org.jeecg.modules.index.dto.*;
import org.jeecg.modules.rencai.PingYinUtil;
import org.jeecg.modules.rencai.bo.*;
import org.jeecg.modules.rencai.entity.*;
import org.jeecg.modules.rencai.service.*;
import org.jeecg.modules.rencai.vo.EduStationVO;
import org.jeecg.modules.rencai.vo.FullInfoVO;
import org.jeecg.modules.rencai.vo.ProfessionVO;
import org.jeecgframework.poi.excel.ExcelImportUtil;
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
import org.jeecgframework.poi.excel.entity.ExportParams;
import org.jeecgframework.poi.excel.entity.ImportParams;
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.io.IOException;
import java.util.*;
import java.util.stream.Collectors;

@Slf4j
@Api(tags = "首页接口2.0")
@RestController
@RequestMapping("/rencai/index")
public class Index20Controller {
    @Autowired
    private IBaseParkService baseParkService;
    @Autowired
    private IEduInfoService eduInfoService;
    @Autowired
    private IEduStationService eduStationService;
    @Autowired
    private IInstituteService instituteService;
    @Autowired
    private IBaseProductService baseProductService;
    @Autowired
    private IEduSummaryService eduSummaryService;
    //省市联动
    //https://blog.csdn.net/weixin_33835690/article/details/89070244

    @ApiOperation(value = "学校-分页列表查询", notes = "学校-分页列表查询")
    @PostMapping(value = "/querySchoolPageList")
    public Result<EduListBO> querySchoolPageList(@RequestBody ProfessionPageDTO dto) {
        Result<EduListBO> result = new Result<>();
        EduListBO eduListBO = new EduListBO();
        int pageNo = dto.getPageNo() == null ? 1 : dto.getPageNo();
        int pageSize = dto.getPageSize() == null ? 10 : dto.getPageSize();
        String type = "";
        String mainType = dto.getMainType();
        if (StringUtils.isBlank(dto.getType())) {
            //查所有类型
            type = "4";
        } else {
            switch (dto.getType()) {
                case "benke":
                    type = "1";
                    break;
                case "gaozhi":
                    type = "2";
                    break;
                case "zhongzhi":
                    type = "3";
                    break;
                default:
                    type = dto.getType();
                    break;

            }
        }
        String title = "";
        String province = dto.getProvince();
        if (StringUtils.isBlank(province)) {
            province = "全国";
        }
        switch (mainType){
            case "1":
                title += "机械装备产业";
                break;
            case "2":
                title += "数字产业";
                break;
            case "3":
                title += "文化旅游产业";
            case "4":
                title += "氟化工";
                break;
        }
        switch (type) {
            case "1":
                title += "本科院校";
                break;
            case "2":
                title += "高等院校";
                break;
            case "3":
                title += "中等职业院校";
                break;
            case "4":
                title += "院校";
                break;
        }
        title = province + title;
        int schoolTotal = 0;
        int studentTotal = 0;
        IPage<EduBO> eduPageList = new Page<>();
        List<EduBO> resList = new ArrayList<>();
        List<String> queryParam1 = new ArrayList<>();
        List<String> queryParam2 = new ArrayList<>();
//        List<String> queryParam3 = new ArrayList<>();
//        List<String> queryParam4 = new ArrayList<>();
        queryParam1.add("211");
        queryParam1.add("985");
        if (StringUtils.isBlank(dto.getProfessions())) {
            LambdaQueryWrapper<EduStation> queryWrapper = new LambdaQueryWrapper<>();
            queryWrapper.eq(EduStation::getMainType,mainType);
            if (StringUtils.isNotBlank(dto.getSchoolNature())) {
                if (dto.getSchoolNature().indexOf("211")!=-1 && dto.getSchoolNature().indexOf("985")!=-1){
                    queryWrapper.like(EduStation::getSchoolNature, "211");
                    queryWrapper.like(EduStation::getSchoolNature, "985");
                } else if (dto.getSchoolNature().indexOf("985")!=-1){
                    queryWrapper.like(EduStation::getSchoolNature, "985");
                } else {
                    queryWrapper.like(EduStation::getSchoolNature, "211");
                }
            }
//            if ("全国".equals(province)){
//                if ("1".equals(type)){
//                    queryWrapper.and(wrapper->wrapper.eq(EduStation::getType,"1").or().eq(EduStation::getType,"4"));
//                }
//            } else {
//                if (province.indexOf("福建")!=-1){
//                    queryWrapper.eq(EduStation::getType,type);
//                } else if ("1".equals(type)){
//                    queryWrapper.eq(EduStation::getType,"4");
//                    queryWrapper.like(EduStation::getArea,province);
//                } else {
//                    hasNoData = true;
//                }
//            }
            if (!"全国".equals(province)) {
                queryWrapper.like(EduStation::getProvince, province);
            }
            if (!"4".equals(type)) {
                queryWrapper.eq(EduStation::getType, type);
            }
            List<EduStation> pageList = eduStationService.list(queryWrapper);
            for (EduStation edu : pageList) {
                if (StringUtils.isNotBlank(edu.getStudentNum()) && !"暂无数据".equals(edu.getStudentNum())) {
                    studentTotal += Integer.valueOf(edu.getStudentNum());
                }
                EduBO eduBO = new EduBO();
                eduBO.setId(edu.getId());
                eduBO.setContactWay(edu.getContactWay());
                eduBO.setSchoolName(edu.getSchoolName());
                eduBO.setTotal(edu.getStudentNum());
                resList.add(eduBO);
            }
        } else {

            String professions = dto.getProfessions();
            List<String> professionList = Arrays.asList(professions.split(","));
            if (professionList.size() == 0) {
                professionList = null;
            }
            ProfessionVO professionVO = new ProfessionVO();
            if (!"全国".equals(province)) {
                professionVO.setProvince(province);
            }
            if (!"4".equals(type)) {
                professionVO.setType(type);
            }
            professionVO.setProfessions(professionList);
//            professionVO.setSchoolNature(dto.getSchoolNature());
            if (StringUtils.isNotBlank(dto.getSchoolNature())) {
                int flag = 0;
                if (dto.getSchoolNature().indexOf("211")!=-1){
                    professionVO.setSchoolNature("211");
                    flag +=1;
                }
                if (dto.getSchoolNature().indexOf("985")!=-1){
                    professionVO.setSchoolNature("985");
                    flag +=1;
                }
                if (flag>1){
                    professionVO.setSchoolNature("211985");
                }
            }
            professionVO.setMainType(mainType);
            List<FullInfoVO> queryRes = eduInfoService.queryFullInfoByProfession(professionVO);
            Map<String, EduBO> map = new HashMap<>();
            for (FullInfoVO infoVO : queryRes) {
                if (!"全国".equals(province)) {

                }
                EduBO eduBO = null;
                if (!map.containsKey(infoVO.getSchoolName())) {
                    eduBO = new EduBO();
                    eduBO.setId(infoVO.getId());
                    eduBO.setContactWay(infoVO.getContactWay());
                    eduBO.setSchoolName(infoVO.getSchoolName());
                    eduBO.setTotal("0");
                    eduBO.setProvince(infoVO.getProvince());
                    map.put(infoVO.getSchoolName(), eduBO);
                }
                String numV = infoVO.getProfessionTotal();
                if (StringUtils.isNotBlank(numV) && !"—".equals(numV)) {
                    eduBO = map.get(infoVO.getSchoolName());
                    eduBO.setTotal((Integer.valueOf(eduBO.getTotal()) + Integer.valueOf(numV)) + "");
                    map.replace(infoVO.getSchoolName(), eduBO);
                }
            }
            for (Map.Entry<String, EduBO> m : map.entrySet()) {
                studentTotal += Integer.valueOf(m.getValue().getTotal());
                resList.add(m.getValue());
            }

        }

        schoolTotal = resList.size();
        resList = resList.stream().skip(pageSize * (pageNo - 1)).limit(pageSize).collect(Collectors.toList());
        for (EduBO eduBO : resList) {
            try {
                Result<EduInfoBO> res = querySchoolById(eduBO.getId(),dto.getMainType());
                if (res.getCode() == 200) {
                    eduBO.setSchoolInfo(res.getResult());
                }
            } catch (Exception e) {

            }
        }
        eduPageList.setCurrent(pageNo);
        eduPageList.setTotal(schoolTotal);
        eduPageList.setRecords(resList);
        eduListBO.setTitle(title);
        eduListBO.setSchoolTotal(schoolTotal + "");
        eduListBO.setStudentTotal(studentTotal + "");

        eduPageList.getRecords().sort(new Comparator<EduBO>() {
            @Override
            public int compare(EduBO o1, EduBO o2) {
                return Integer.valueOf(o2.getTotal())-Integer.valueOf(o1.getTotal());
            }
        });
        eduListBO.setEduPageList(eduPageList);

        if ("全国".equals(province)) {
            if ("1".equals(type)) {
                queryParam2.addAll(eduInfoService.queryDistinctProfession("1", "", "",mainType));
            } else if ("4".equals(type)) {
                queryParam2.addAll(eduInfoService.queryDistinctProfession("1", "", "",mainType));
                queryParam2.addAll(eduInfoService.queryDistinctProfession("2", "", "",mainType));
                queryParam2.addAll(eduInfoService.queryDistinctProfession("3", "", "",mainType));
            } else {
                queryParam2.addAll(eduInfoService.queryDistinctProfession(type, "", "",mainType));
            }
        } else {
            queryParam2.addAll(eduInfoService.queryDistinctProfession("1", province, "",mainType));
            queryParam2.addAll(eduInfoService.queryDistinctProfession("2", province, "",mainType));
            queryParam2.addAll(eduInfoService.queryDistinctProfession("3", province, "",mainType));
        }
        if ("1".equals(type)) {
            eduListBO.setQueryParam1(queryParam1);
        }
        eduListBO.setQueryParam2(queryParam2);
//        eduListBO.setQueryParam3(queryParam3);
//        eduListBO.setQueryParam4(queryParam4);
        result.setResult(eduListBO);
        return result;
    }



    @ApiOperation(value = "city 学校-市  本科、高职、中职 分页", notes = "本科、高职、中职 分页")
    @PostMapping(value = "/queryCitySchoolPageList")
    public Result<EduListBO> queryCitySchoolPageList(@RequestBody CityProfessionPageDTO dto) {
        Result<EduListBO> result = new Result<>();
        EduListBO eduListBO = new EduListBO();
        int pageNo = dto.getPageNo() == null ? 1 : dto.getPageNo();
        int pageSize = dto.getPageSize() == null ? 10 : dto.getPageSize();
        String type = "";
        if (StringUtils.isBlank(dto.getProvince())) {
            return result.error500("省份为空");
        }
        String mainType = dto.getMainType();
        if (StringUtils.isBlank(dto.getType())) {
            //查所有类型
            type = "4";
        } else {
            switch (dto.getType()) {
                case "benke":
                    type = "1";
                    break;
                case "gaozhi":
                    type = "2";
                    break;
                case "zhongzhi":
                    type = "3";
                    break;
                default:
                    type = dto.getType();
                    break;

            }
        }
        String title = "";
        String city = dto.getCity();
        if (StringUtils.isBlank(city)) {
            city = dto.getProvince();
        } else {
            city = dto.getProvince() + city;
        }
        switch (mainType){
            case "1":
                title += "机械装备产业";
                break;
            case "2":
                title += "数字产业";
                break;
            case "3":
                title += "文化旅游产业";
            case "4":
                title += "氟化工";
                break;
        }
        switch (type) {
            case "1":
                title += "本科院校";
                break;
            case "2":
                title += "高等院校";
                break;
            case "3":
                title += "中等职业院校";
                break;
            case "4":
                title += "院校";
                break;
        }
        title = city + title;
        int schoolTotal = 0;
        int studentTotal = 0;
        IPage<EduBO> eduPageList = new Page<>();
        List<EduBO> resList = new ArrayList<>();
        List<String> queryParam1 = new ArrayList<>();
        List<String> queryParam2 = new ArrayList<>();
        queryParam1.add("211");
        queryParam1.add("985");
        if (StringUtils.isBlank(dto.getProfessions())) {
            LambdaQueryWrapper<EduStation> queryWrapper = new LambdaQueryWrapper<>();
            queryWrapper.eq(EduStation::getMainType,mainType);
            if (StringUtils.isNotBlank(dto.getSchoolNature())) {
                queryWrapper.like(EduStation::getSchoolNature, dto.getSchoolNature());
            }
            queryWrapper.like(EduStation::getProvince, dto.getProvince());
            if (StringUtils.isNotBlank(dto.getCity())) {
                queryWrapper.like(EduStation::getCity, dto.getCity());
            }
            if (!"4".equals(type)) {
                //全省
                queryWrapper.eq(EduStation::getType, type);
            }
            List<EduStation> pageList = eduStationService.list(queryWrapper);
            for (EduStation edu : pageList) {
                if (StringUtils.isNotBlank(edu.getStudentNum()) && !"暂无数据".equals(edu.getStudentNum())) {
                    studentTotal += Integer.valueOf(edu.getStudentNum());
                }
                EduBO eduBO = new EduBO();
                eduBO.setId(edu.getId());
                eduBO.setContactWay(edu.getContactWay());
                eduBO.setSchoolName(edu.getSchoolName());
                eduBO.setTotal(edu.getStudentNum());
                resList.add(eduBO);
            }
        } else {
            String professions = dto.getProfessions();
            List<String> professionList = Arrays.asList(professions.split(","));
            if (professionList.size() == 0) {
                professionList = null;
            }
            ProfessionVO professionVO = new ProfessionVO();
            professionVO.setProvince(dto.getProvince());
            if (!"4".equals(type)) {
                professionVO.setType(type);
            }
            professionVO.setProfessions(professionList);
            professionVO.setCity(dto.getCity());
            professionVO.setSchoolNature(dto.getSchoolNature());
            professionVO.setMainType(mainType);
            List<FullInfoVO> queryRes = eduInfoService.queryFullInfoByProfession(professionVO);
            Map<String, EduBO> map = new HashMap<>();
            for (FullInfoVO infoVO : queryRes) {
                EduBO eduBO = null;
                if (!map.containsKey(infoVO.getSchoolName())) {
                    eduBO = new EduBO();
                    eduBO.setId(infoVO.getId());
                    eduBO.setContactWay(infoVO.getContactWay());
                    eduBO.setSchoolName(infoVO.getSchoolName());
                    eduBO.setTotal("0");
                    map.put(infoVO.getSchoolName(), eduBO);
                }
                String numV = infoVO.getProfessionTotal();
                if (StringUtils.isNotBlank(numV) && !"—".equals(numV)) {
                    eduBO = map.get(infoVO.getSchoolName());
                    eduBO.setTotal((Integer.valueOf(eduBO.getTotal()) + Integer.valueOf(numV)) + "");
                    map.replace(infoVO.getSchoolName(), eduBO);
                }
            }
            for (Map.Entry<String, EduBO> m : map.entrySet()) {
                studentTotal += Integer.valueOf(m.getValue().getTotal());
                resList.add(m.getValue());
            }
        }

        schoolTotal = resList.size();
        resList = resList.stream().skip(pageSize * (pageNo - 1)).limit(pageSize).collect(Collectors.toList());
        for (EduBO eduBO : resList) {
            try {
                Result<EduInfoBO> res = querySchoolById(eduBO.getId(),dto.getMainType());
                if (res.getCode() == 200) {
                    eduBO.setSchoolInfo(res.getResult());
                }
            } catch (Exception e) {

            }
        }
        eduPageList.setCurrent(pageNo);
        eduPageList.setTotal(schoolTotal);
        eduPageList.setRecords(resList);
        eduListBO.setTitle(title);
        eduListBO.setSchoolTotal(schoolTotal + "");
        eduListBO.setStudentTotal(studentTotal + "");
        eduListBO.setEduPageList(eduPageList);
        if ("1".equals(type)) {
            queryParam2.addAll(eduInfoService.queryDistinctProfession("1", dto.getProvince(), dto.getCity(),mainType));
        } else if ("4".equals(type)) {
            queryParam2.addAll(eduInfoService.queryDistinctProfession("1", dto.getProvince(), dto.getCity(),mainType));
            queryParam2.addAll(eduInfoService.queryDistinctProfession("2", dto.getProvince(), dto.getCity(),mainType));
            queryParam2.addAll(eduInfoService.queryDistinctProfession("3", dto.getProvince(), dto.getCity(),mainType));
        } else {
            queryParam2.addAll(eduInfoService.queryDistinctProfession(type, dto.getProvince(), dto.getCity(),mainType));
        }
        if ("1".equals(type)) {
            eduListBO.setQueryParam1(queryParam1);
        }
        eduListBO.setQueryParam2(queryParam2);
//        eduListBO.setQueryParam3(queryParam3);
//        eduListBO.setQueryParam4(queryParam4);
        result.setResult(eduListBO);
        return result;
    }


    @ApiOperation(value = "学校-通过id查询", notes = "学校-通过id查询")
    @GetMapping(value = "/querySchoolById")
    public Result<EduInfoBO> querySchoolById(@RequestParam(name = "id", required = true) String id, @RequestParam String mainType) {
        Result<EduInfoBO> result = new Result<>();
        EduStation eduStation = eduStationService.getById(id);
        if (ObjectUtil.isEmpty(eduStation) || !eduStation.getMainType().equals(mainType)) {
            return result.error500("学校不存在");
        }
        EduInfoBO eduInfoBO = new EduInfoBO();
        String area = eduStation.getProvince();
        if (StringUtils.isNotBlank(eduStation.getCity())) {
            area += "-" + eduStation.getCity();
        }
        eduInfoBO.setArea(area);
        eduInfoBO.setSchoolName(eduStation.getSchoolName());
        eduInfoBO.setContactWay(eduStation.getContactWay());
        eduInfoBO.setStudentNum(eduStation.getStudentNum());

        String type = "";
        switch (eduStation.getType()){
            case "1":
                type = "本科";
                break;
            case "2":
                type = "高职";
                break;
            case "3":
                type = "中职";
                break;
        }
        eduInfoBO.setType(type);
        eduInfoBO.setSchoolNature(eduStation.getSchoolNature());
        List<EduInfoCollegeBO> professionNumList = new ArrayList<>();
        List<EduInfo> eduInfoList = eduInfoService.list(new LambdaQueryWrapper<EduInfo>().eq(EduInfo::getSchoolId, eduStation.getId()).eq(EduInfo::getMainType,mainType));
        eduInfoList.sort(new Comparator<EduInfo>() {
            @Override
            public int compare(EduInfo o1, EduInfo o2) {
                return Integer.valueOf(o2.getStudentNum())-Integer.valueOf(o1.getStudentNum()) ;
            }
        });
        for (EduInfo info : eduInfoList) {
            ProfessionNumBO numBO = new ProfessionNumBO();
            numBO.setProfession(info.getProfession());
            numBO.setProfessionTotal(info.getStudentNum());
            List<ProfessionNumBO> numList = null;
            for (EduInfoCollegeBO collegeBO:professionNumList){
                if (collegeBO.getCollege().equals(info.getCollege())){
                    numList = collegeBO.getProfessionNumList();
                }
            }
            if (numList == null){
                numList = new ArrayList<ProfessionNumBO>();
                EduInfoCollegeBO collegeBO = new EduInfoCollegeBO();
                collegeBO.setCollege(StringUtils.isBlank(info.getCollege())?"":info.getCollege());
                collegeBO.setProfessionNumList(numList);
                professionNumList.add(collegeBO);
            }
            numList.add(numBO);
        }
        for (EduInfoCollegeBO collegeBO:professionNumList){
            int total = 0;
            for (ProfessionNumBO numBO: collegeBO.getProfessionNumList()){
                total+= Integer.valueOf(numBO.getProfessionTotal());
            }
            collegeBO.setCollegePersons(total+"");
        }
        eduInfoBO.setProfessionNumList(professionNumList);
        result.setResult(eduInfoBO);
        return result;
    }


    @ApiOperation(value = "获取专业列表 ", notes = "获取专业列表")
    @GetMapping(value = "/queryDistinctProfession")
    public Result<?> queryDistinctProfession(
            @ApiParam(value = "市：''为全省", required = false)
            @RequestParam(required = false) String city,
            @ApiParam(value = "省份：''为全国", required = false)
            @RequestParam(required = false) String province,
            @RequestParam(required = false)
            @ApiParam(value = "类别  1 本科 2 高职 3 中职", required = false)
                    String type,
            @RequestParam(required = false) String mainType) {
        if (StringUtils.isBlank(mainType)){
            mainType = "1";
        }
        if (StringUtils.isBlank(type)){
            type = "1";
        }
        List<String> list = eduInfoService.queryDistinctProfession(type, province, city,mainType);
        return Result.ok(list);
    }

    @ApiOperation(value = "获取专业列表 按字母", notes = "获取专业列表 按字母")
    @GetMapping(value = "/queryDistinctProfessionByLetter")
    public Result<?> queryDistinctProfessionByLetter(
            @ApiParam(value = "市：''为全省", required = false)
            @RequestParam(required = false) String city,
            @ApiParam(value = "省份：''为全国", required = false)
            @RequestParam(required = false) String province,
            @RequestParam(required = false)
            @ApiParam(value = "类别  1 本科 2 高职 3 中职 4 研究院 5 园区  6 生产基地", required = false)
                    String type,
            @RequestParam(required = false) String schoolNature,
            @RequestParam(required = false) String mainType) {
        if (StringUtils.isBlank(mainType)){
            mainType = "1";
        }
        if (StringUtils.isBlank(type)){
            type = "1";
        }
        List<String> list = new ArrayList<>();
        if ("1".equals(type)||"2".equals(type)||"3".equals(type)){
            if (StringUtils.isNotBlank(schoolNature)){
                String school985 = "";
                String school211 = "";
                if (schoolNature.indexOf("985")!=-1){
                    school985 = "985";
                }
                if (schoolNature.indexOf("211")!=-1){
                    school211 = "211";
                }
                list = eduInfoService.queryDistinctProfession(type, province, city,mainType,school211,school985);
            } else {
                list = eduInfoService.queryDistinctProfession(type, province, city,mainType);
            }
        }  else if ("4".equals(type)){
            list = instituteService.queryTypeList(province,city,mainType);
        } else if ("5".equals(type)){
            list = baseParkService.queryTypeList(province,city,mainType);
        }  else if ("6".equals(type)){
            list = baseProductService.queryTypeList(province,city,mainType);
        }
        String[] arrays = new String[]{"A","B","C","D","E","F","G","H",
                "I","J","K","L","M","N","O","P",
                "Q","R","S","T","U","V","W","X",
                "Y","Z"
        };
        List<PingyinBO> resList = new ArrayList<>();
        for (String s:arrays){
            PingyinBO bo = new PingyinBO();
            bo.setLetter(s);
            bo.setLetterList(new ArrayList<String>());
            resList.add(bo);
        }
        for (String s:list){
            if (StringUtils.isBlank(s)){
                continue;
            }
            String first = "";
            for (int index = 0;index<=s.length()-1;index++) {   //将字符串拆开成单个的字符
                String w = s.substring(index, index + 1);
                if (w.compareTo("\u4e00") > 0 && w.compareTo("\u9fa5") < 0) {// \u4e00-\u9fa5 中文汉字的范围
//                    System.out.println("第一个中文的索引位置:" + index + ",值是：" + w);
                    first = PingYinUtil.getPYIndexStr(s.substring(index,index+1),true);
                    break;
                }
            }
            for (PingyinBO bo:resList){
                if (bo.getLetter().equals(first)){
                    bo.getLetterList().add(s);
                }
            }
        }
        List<List<String>> backData = new ArrayList<>();
        for (PingyinBO bo:resList){
            backData.add(bo.getLetterList());
        }
        return Result.ok(backData);
    }

    @ApiOperation(value = "获取研究院类型列表 ", notes = "获取研究院类型列表")
    @GetMapping(value = "/queryInstituteTypeList")
    public Result<?> queryInstituteTypeList(
            @ApiParam(value = "市：''为全省", required = false)
            @RequestParam(required = false) String city,
            @ApiParam(value = "省份：''为全国", required = false)
            @RequestParam(required = false) String province, @RequestParam String mainType) {
        return Result.ok(instituteService.queryTypeList(province, city,mainType));
    }

    @ApiOperation(value = "获取园区基地类型列表 ", notes = "获取园区基地类型列表")
    @GetMapping(value = "/queryBaseParkTypeList")
    public Result<?> queryBaseParkTypeList(
            @ApiParam(value = "省份：''为全国", required = false)
            @RequestParam(required = false) String province, @RequestParam String mainType) {
        return Result.ok(baseParkService.queryTypeList(province,mainType));
    }

    @ApiOperation(value = "new 获取左侧搜索类型 六合一", notes = "获取左侧搜索类型")
    @GetMapping(value = "/queryLeftSearchType")
    public Result<?> queryLeftSearchType(@ApiParam(value = "省份：''为全国", required = false)
                                         @RequestParam(required = false) String province, @RequestParam String mainType) {
        Map<String, List<String>> map = new HashMap<>();
        map.put("benke", eduInfoService.queryDistinctProfession("1", province, "",mainType));
        map.put("gaozhi", eduInfoService.queryDistinctProfession("2", province, "",mainType));
        map.put("zhongzhi", eduInfoService.queryDistinctProfession("3", province, "",mainType));
        map.put("yanjiuyuan", instituteService.queryTypeList(province, "",mainType));
        map.put("yuanqujidi", baseParkService.queryTypeList(province,mainType));
        map.put("shengchanjidi", baseProductService.queryTypeList(province,"",mainType));
        return Result.ok(map);
    }

    @ApiOperation(value = "new 根据左侧搜索类型 获得地图统计结果", notes = "根据左侧搜索类型 获得地图统计结果")
    @PostMapping(value = "/queryMapData")
    public Result<?> queryMapData(@Valid @RequestBody MapDataDTO dto) {
        List<NameValueBO> resList = new ArrayList<>();
        List<NameValueBO> tmpList = new ArrayList<>();
        String mainType = dto.getMainType();
        List<String> professions = null;
        if (StringUtils.isNotBlank(dto.getProfessions())){
            professions = Arrays.asList(dto.getProfessions().split(","));
        }
        if ("benke".equals(dto.getSearchType())){
            dto.setSearchType("1");
            dto.setType("1");
        } else if ("gaozhi".equals(dto.getSearchType())){
            dto.setSearchType("1");
            dto.setType("2");
        } else if ("zhongzhi".equals(dto.getSearchType())){
            dto.setSearchType("1");
            dto.setType("3");
        } else if ("yanjiuyuan".equals(dto.getSearchType())){
            dto.setSearchType("2");
            dto.setType("4");
        } else if ("yuanqujidi".equals(dto.getSearchType())){
            dto.setSearchType("3");
            dto.setType("5");
        } else if ("shengchanjidi".equals(dto.getSearchType())){
            dto.setSearchType("4");
            dto.setType("6");
        }
        String string985 = "";
        String string211 = "";
        String search = dto.getSearch();
        if ("1".equals(dto.getSearchType())){
            if (StringUtils.isNotBlank(search)){
                if (search.indexOf("985")!=-1){
                    string985 = "985";
                    if (search.length()>4){
                        search = search.replace("985,","");
                    } else {
                        search = search.replace("985","");
                    }
                }
                if (search.indexOf("211")!=-1){
                    string211 = "211";
                    if (search.length()>4){
                        search = search.replace("211,","");
                    } else {
                        search = search.replace("211","");
                    }
                }
                if (search.length()>0){
                    professions = Arrays.asList(search.split(","));
                }
            }
        } else {
            if (StringUtils.isNotBlank(search)){
                professions = Arrays.asList(search.split(","));
            }
        }
        if ("1".equals(dto.getSearchType())||("1".equals(dto.getType())||"2".equals(dto.getType())||"3".equals(dto.getType()))){

            if (StringUtils.isNotBlank(dto.getSchoolNature())){
                if ("211".equals(dto.getSchoolNature())){
                    string211 = "211";
                } else if ("985".equals(dto.getSchoolNature())){
                    string985 = "985";
                }
            }
            if (StringUtils.isNotBlank(dto.getProvince())) {
                tmpList = eduInfoService.countCityByProfession(dto.getProvince(), dto.getType(), professions,mainType);
            } else {
                tmpList = eduInfoService.countByProfession(dto.getType(),professions, string211, string985,mainType);
            }
        } else if ("2".equals(dto.getSearchType())||"4".equals(dto.getType())) {

            if (StringUtils.isNotBlank(dto.getProvince())) {
                tmpList = instituteService.countCityByType(dto.getProvince(), professions,mainType);
            } else {
                tmpList = instituteService.countByType(professions,mainType);
            }
        } else if ("3".equals(dto.getSearchType())||"5".equals(dto.getType())) {
            if (StringUtils.isNotBlank(dto.getProvince())) {
                tmpList = baseParkService.countCityByType(dto.getProvince(), professions,mainType);
            } else {
                tmpList = baseParkService.countByType(professions,mainType);
            }
        } else if ("4".equals(dto.getSearchType())||"6".equals(dto.getType())) {
            if (StringUtils.isNotBlank(dto.getProvince())) {
                tmpList = baseProductService.countCity(dto.getProvince(),professions,mainType);
            } else {
                tmpList = baseProductService.countProvince(professions,mainType);
            }
        }
//        String[] provinces = new String[]{"广东", "山东", "河南", "四川",
//                "江苏", "河北", "湖南", "安徽",
//                "湖北", "浙江", "广西", "云南",
//                "江西", "辽宁", "福建", "陕西",
//                "黑龙江", "山西", "贵州", "重庆",
//                "吉林", "甘肃", "内蒙古", "新疆",
//                "上海", "台湾", "北京", "天津",
//                "海南", "宁夏", "青海", "西藏"};

        if (StringUtils.isBlank(dto.getProvince())) {
//            for (String s : Arrays.asList(provinces)) {
//                boolean flag = false;
//                for (NameValueBO nv : tmpList) {
//                    if (s.equals(nv.getName())) {
//                        flag = true;
//                    }
//                }
//                if (!flag) {
//                    NameValueBO nnv = new NameValueBO();
//                    nnv.setName(s);
//                    nnv.setNum(0);
//                    resList.add(nnv);
//                }
//            }
            resList.addAll(tmpList);
        } else {
//            if (dto.getProvince().indexOf("福建") != -1) {
//                String[] fjcity = new String[]{"福州", "厦门", "莆田", "三明", "泉州", "漳州", "南平", "龙岩", "宁德"};
//                for (String s : Arrays.asList(fjcity)) {
//                    boolean flag = false;
//                    for (NameValueBO nv : tmpList) {
//                        if (s.equals(nv.getName())) {
//                            flag = true;
//                        }
//                    }
//                    if (!flag) {
//                        NameValueBO nnv = new NameValueBO();
//                        nnv.setName(s);
//                        nnv.setNum(0);
//                        resList.add(nnv);
//                    }
//                }
//            }
            resList.addAll(tmpList);
            for (NameValueBO nv : resList) {
                if (StringUtils.isBlank(nv.getName())){
                    continue;
                }
                if (!nv.getName().endsWith("市")) {
                    nv.setName(nv.getName() + "市");
                }
            }

        }
        return Result.ok(resList);
    }


    @ApiOperation(value = "研究院-分页列表查询", notes = "研究院-分页列表查询")
    @GetMapping(value = "/queryInstitutePageList")
    public Result<IPage<Institute>> queryInstitutePageList(Institute institute,
                                                           @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
                                                           @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
                                                           HttpServletRequest req) {
        Result<IPage<Institute>> result = new Result<>();
        LambdaQueryWrapper<Institute> queryWrapper =  new LambdaQueryWrapper<>();
        queryWrapper.eq(Institute::getMainType,institute.getMainType());
        Page<Institute> page = new Page<Institute>(pageNo, pageSize);
        IPage<Institute> pageList = instituteService.page(page, queryWrapper);
        result.setResult(pageList);
        return result;
    }

    @ApiOperation(value = "基地、园区-分页列表查询", notes = "基地、园区-分页列表查询")
    @GetMapping(value = "/queryBaseParkPageList")
    public Result<IPage<BasePark>> queryBaseParkPageList(BasePark basePark,
                                                         @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
                                                         @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
                                                         HttpServletRequest req) {
        Result<IPage<BasePark>> result = new Result<>();
        LambdaQueryWrapper<BasePark> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(BasePark::getMainType,basePark.getMainType());
        Page<BasePark> page = new Page<BasePark>(pageNo, pageSize);
        IPage<BasePark> pageList = baseParkService.page(page, queryWrapper);
        result.setResult(pageList);
        return result;
    }

    @ApiOperation(value = "生产基地-分页列表查询", notes = "生产基地-分页列表查询")
    @GetMapping(value = "/queryBaseProductPageList")
    public Result<IPage<BaseProduct>> queryBaseProductPageList(BaseProduct baseProduct,
                                                               @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
                                                               @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
                                                               HttpServletRequest req) {
        Result<IPage<BaseProduct>> result = new Result<>();
        LambdaQueryWrapper<BaseProduct> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(BaseProduct::getMainType,baseProduct.getMainType());
        Page<BaseProduct> page = new Page<BaseProduct>(pageNo, pageSize);
        IPage<BaseProduct> pageList = baseProductService.page(page, queryWrapper);
        result.setResult(pageList);
        return result;
    }


    @ApiOperation(value = "生产基地、园区基地、研究院-分页列表查询  三合一", notes = "生产基地、园区基地、研究院-分页列表查询")
    @PostMapping(value = "/queryBaseProductInstitutePage")
    public Result<?> queryBaseProductInstitutePage(@Valid @RequestBody SearchThreeDTO dto) {
        Map<String, Object> map = new HashMap<>();
        String title = "";
        int pageNo = dto.getPageNo() == null ? 1 : dto.getPageNo();
        int pageSize = dto.getPageSize() == null ? 10 : dto.getPageSize();
        IPage<BaseProductInstituteBO> resPage = new Page<BaseProductInstituteBO>(pageNo, pageSize);
        List<BaseProductInstituteBO> resList = new ArrayList<>();
        String mainType = dto.getMainType();
        switch (mainType){
            case "1":
                title += "机械装备产业";
                break;
            case "2":
                title += "数字产业";
                break;
            case "3":
                title += "文化旅游产业";
            case "4":
                title += "氟化工";
                break;
        }
        switch (dto.getSearchType()) {
            case "yanjiuyuan":
                title += "研究院";
                LambdaQueryWrapper<Institute> insqw = new LambdaQueryWrapper<>();
                Page<Institute> page = new Page<Institute>(pageNo, pageSize);
                insqw.eq(Institute::getMainType,mainType);
                if (StringUtils.isNotBlank(dto.getProvince())) {
                    insqw.like(Institute::getProvince, dto.getProvince());
                    title = dto.getProvince() + title;
                } else {
                    title = "全国" + title;
                }
                if (StringUtils.isNotBlank(dto.getSearch())) {
                    List<String> searchList = Arrays.asList(dto.getSearch().split(","));
                    for (String s : searchList) {
                        if (StringUtils.isBlank(s)) {
                            searchList.remove(s);
                        }
                    }
                    insqw.in(Institute::getType, searchList);
                }
                IPage<Institute> pageList1 = instituteService.page(page, insqw);
//                map.put("pageList", pageList1);
                for (Institute institute : pageList1.getRecords()) {
                    BaseProductInstituteBO instituteBO = new BaseProductInstituteBO();
                    instituteBO.setName(institute.getInstituteName());
                    instituteBO.setProvince(institute.getProvince());
                    instituteBO.setCity(institute.getCity());
                    instituteBO.setType(institute.getType());
                    resList.add(instituteBO);
                }
                map.put("title", title);
                map.put("queryParam", instituteService.queryTypeList(dto.getProvince(), "",mainType));
                map.put("summary", instituteService.countByType(null,mainType));
                map.put("total", pageList1.getRecords().size());
                resPage.setTotal(pageList1.getTotal());
                break;
            case "yuanqujidi":
                title += "园区、基地";
                LambdaQueryWrapper<BasePark> parkqw = new LambdaQueryWrapper<>();
                Page<BasePark> page2 = new Page<BasePark>(pageNo, pageSize);
                parkqw.eq(BasePark::getMainType,mainType);
                if (StringUtils.isNotBlank(dto.getProvince())) {
                    parkqw.eq(BasePark::getProvince, dto.getProvince());
                    title = dto.getProvince() + title;
                } else {
                    title = "全国" + title;
                }
                if (StringUtils.isNotBlank(dto.getSearch())) {
                    List<String> searchList = Arrays.asList(dto.getSearch().split(","));
                    for (String s : searchList) {
                        if (StringUtils.isBlank(s)) {
                            searchList.remove(s);
                        }
                    }
                    parkqw.in(BasePark::getType, searchList);
                }
                IPage<BasePark> pageList2 = baseParkService.page(page2, parkqw);
//                map.put("pageList", pageList2);
                for (BasePark basePark : pageList2.getRecords()) {
                    BaseProductInstituteBO instituteBO = new BaseProductInstituteBO();
                    instituteBO.setName(basePark.getParkName());
                    instituteBO.setProvince(basePark.getProvince());
                    instituteBO.setCity(basePark.getCity());
                    instituteBO.setType(basePark.getType());
                    instituteBO.setUrl(basePark.getUrl());
                    resList.add(instituteBO);
                }
                map.put("title", title);
                map.put("queryParam", baseParkService.queryTypeList(dto.getProvince(),mainType));
                map.put("summary", baseParkService.countByType(null,mainType));
                map.put("total", pageList2.getRecords().size());
                resPage.setTotal(pageList2.getTotal());
                break;
            case "shengchanjidi":
                title  += "生产基地";
                LambdaQueryWrapper<BaseProduct> bpqw = new LambdaQueryWrapper<>();
                Page<BaseProduct> page3 = new Page<BaseProduct>(pageNo, pageSize);
                bpqw.eq(BaseProduct::getMainType,mainType);
                if (StringUtils.isNotBlank(dto.getProvince())) {
                    bpqw.like(BaseProduct::getProvince, dto.getProvince());
                    title = dto.getProvince() + title;
                } else {
                    title = "全国" + title;
                }
                IPage<BaseProduct> pageList3 = baseProductService.page(page3, bpqw);
//                map.put("pageList", pageList3);
                for (BaseProduct baseProduct : pageList3.getRecords()) {
                    BaseProductInstituteBO instituteBO = new BaseProductInstituteBO();
                    instituteBO.setName(baseProduct.getName());
                    instituteBO.setProvince(baseProduct.getProvince());
                    instituteBO.setCity(baseProduct.getCity());
                    instituteBO.setType(baseProduct.getType());
                    instituteBO.setContent(baseProduct.getBaseContent());
                    resList.add(instituteBO);
                }
                map.put("title", title);
                map.put("queryParam", new ArrayList<>());
                map.put("total", pageList3.getRecords().size());
                resPage.setTotal(pageList3.getTotal());
                break;
        }
        resPage.setRecords(resList);
        map.put("pageList", resPage);
        return Result.ok(map);
    }


    @ApiOperation(value = " city 市   生产基地、园区基地、研究院-分页列表查询  三合一", notes = "生产基地、园区基地、研究院-分页列表查询")
    @PostMapping(value = "/queryCityBaseProductInstitutePage")
    public Result<?> queryCityBaseProductInstitutePage(@Valid @RequestBody CitySearchThreeDTO dto) {
        Map<String, Object> map = new HashMap<>();
        String title = "";
        int pageNo = dto.getPageNo() == null ? 1 : dto.getPageNo();
        int pageSize = dto.getPageSize() == null ? 10 : dto.getPageSize();
        IPage<BaseProductInstituteBO> resPage = new Page<BaseProductInstituteBO>(pageNo, pageSize);
        List<BaseProductInstituteBO> resList = new ArrayList<>();
        if (StringUtils.isBlank(dto.getProvince())) {
            return Result.error("省份为空");
        }
        String mainType = dto.getMainType();
        switch (mainType){
            case "1":
                title += "机械装备产业";
                break;
            case "2":
                title += "数字产业";
                break;
            case "3":
                title += "文化旅游产业";
            case "4":
                title += "氟化工";
                break;
        }
        switch (dto.getSearchType()) {
            case "yanjiuyuan":
                title += "研究院";
                LambdaQueryWrapper<Institute> insqw = new LambdaQueryWrapper<>();
                Page<Institute> page = new Page<Institute>(pageNo, pageSize);
                insqw.like(Institute::getProvince, dto.getProvince());
                insqw.eq(Institute::getMainType,mainType);
                if (StringUtils.isNotBlank(dto.getCity())) {
                    insqw.like(Institute::getCity, dto.getCity());
                    title = dto.getProvince() + dto.getCity() + title;
                } else {
                    title = dto.getProvince() + title;
                }
                if (StringUtils.isNotBlank(dto.getSearch())) {
                    List<String> searchList = Arrays.asList(dto.getSearch().split(","));
                    for (String s : searchList) {
                        if (StringUtils.isBlank(s)) {
                            searchList.remove(s);
                        }
                    }
                    insqw.in(Institute::getType, searchList);
                }
                IPage<Institute> pageList1 = instituteService.page(page, insqw);
//                map.put("pageList", pageList1);
                for (Institute institute : pageList1.getRecords()) {
                    BaseProductInstituteBO instituteBO = new BaseProductInstituteBO();
                    instituteBO.setName(institute.getInstituteName());
                    instituteBO.setProvince(institute.getProvince());
                    instituteBO.setCity(institute.getCity());
                    instituteBO.setType(institute.getType());
                    resList.add(instituteBO);
                }
                map.put("title", title);
                map.put("queryParam", instituteService.queryTypeList(dto.getProvince(), "",mainType));
                map.put("summary", instituteService.countByType(null,mainType));
                map.put("total", pageList1.getRecords().size());
                resPage.setTotal(pageList1.getTotal());
                break;
            case "yuanqujidi":
                title += "园区、基地";
                LambdaQueryWrapper<BasePark> parkqw = new LambdaQueryWrapper<>();
                Page<BasePark> page2 = new Page<BasePark>(pageNo, pageSize);
                parkqw.eq(BasePark::getProvince, dto.getProvince());
                parkqw.eq(BasePark::getMainType,mainType);
                if (StringUtils.isNotBlank(dto.getCity())) {
                    parkqw.like(BasePark::getCity, dto.getCity());
                    title = dto.getProvince() + dto.getCity() + title;
                } else {
                    title = dto.getProvince() + title;
                }
                if (StringUtils.isNotBlank(dto.getSearch())) {
                    List<String> searchList = Arrays.asList(dto.getSearch().split(","));
                    for (String s : searchList) {
                        if (StringUtils.isBlank(s)) {
                            searchList.remove(s);
                        }
                    }
                    parkqw.in(BasePark::getType, searchList);
                }
                IPage<BasePark> pageList2 = baseParkService.page(page2, parkqw);
//                map.put("pageList", pageList2);
                for (BasePark basePark : pageList2.getRecords()) {
                    BaseProductInstituteBO instituteBO = new BaseProductInstituteBO();
                    instituteBO.setName(basePark.getParkName());
                    instituteBO.setProvince(basePark.getProvince());
                    instituteBO.setCity(basePark.getCity());
                    instituteBO.setType(basePark.getType());
                    instituteBO.setUrl(basePark.getUrl());
                    resList.add(instituteBO);
                }
                map.put("title", title);
                map.put("queryParam", baseParkService.queryTypeList(dto.getProvince(),mainType));
                map.put("summary", baseParkService.countByType(null,mainType));
                map.put("total", pageList2.getRecords().size());
                resPage.setTotal(pageList2.getTotal());
                break;
            case "shengchanjidi":
                title += "生产基地";
                LambdaQueryWrapper<BaseProduct> bpqw = new LambdaQueryWrapper<>();
                Page<BaseProduct> page3 = new Page<BaseProduct>(pageNo, pageSize);
                bpqw.eq(BaseProduct::getMainType,mainType);
                bpqw.like(BaseProduct::getProvince, dto.getProvince());
                if (StringUtils.isNotBlank(dto.getCity())) {
                    bpqw.like(BaseProduct::getCity, dto.getCity());
                    title = dto.getProvince() + dto.getCity() + title;
                } else {
                    title = dto.getProvince() + title;
                }
                IPage<BaseProduct> pageList3 = baseProductService.page(page3, bpqw);
//                map.put("pageList", pageList3);
                for (BaseProduct baseProduct : pageList3.getRecords()) {
                    BaseProductInstituteBO instituteBO = new BaseProductInstituteBO();
                    instituteBO.setName(baseProduct.getName());
                    instituteBO.setProvince(baseProduct.getProvince());
                    instituteBO.setCity(baseProduct.getCity());
                    instituteBO.setType(baseProduct.getType());
                    instituteBO.setContent(baseProduct.getBaseContent());
                    resList.add(instituteBO);
                }
                map.put("title", title);
                map.put("queryParam", new ArrayList<>());
                map.put("total", pageList3.getRecords().size());
                resPage.setTotal(pageList3.getTotal());
                break;
        }
        resPage.setRecords(resList);
        map.put("pageList", resPage);
        return Result.ok(map);
    }


    @ApiOperation(value = "获取  生产基地、园区基地、研究院 类型列表 三合一", notes = "获取类型列表")
    @GetMapping(value = "/queryBaseProductInstituteTypeList")
    public Result<?> queryBaseProductInstituteTypeList(
            @RequestParam String searchType,
            @ApiParam(value = "省份：''为全国", required = false)
            @RequestParam(required = false) String province,@RequestParam String mainType) {
        List<String> list = new ArrayList<>();
        switch (searchType) {
            case "yanjiuyuan":
                list = instituteService.queryTypeList(province, "",mainType);
                break;
            case "yuanqujidi":
                list = baseParkService.queryTypeList(province,mainType);
                break;
            case "shengchanjidi":
                break;
        }
        return Result.ok(list);
    }


    @ApiOperation(value = "根据专业筛选获取统计列表 ", notes = "根据专业筛选获取统计列表")
    @PostMapping(value = "/querySummaryByProfession")
    public Result<?> querySummaryByProfession(@RequestBody ProfessionDTO dto) {
        String type = dto.getType();
        String professions = dto.getProfessions();
        List<String> professionList = Arrays.asList(professions.split(","));
        if (professionList.size() == 0) {
            professionList = null;
        }
        ProfessionVO professionVO = new ProfessionVO();
        BeanUtils.copyProperties(dto, professionVO);
        professionVO.setProfessions(professionList);
        professionVO.setMainType(dto.getMainType());
        List<FullInfoVO> queryRes = eduInfoService.queryFullInfoByProfession(professionVO);
        Map<String, Integer> map = new HashMap<>();
        for (FullInfoVO infoVO : queryRes) {
            if (!map.containsKey(infoVO.getArea())) {
                map.put(infoVO.getArea(), 0);
            }
            String numV = infoVO.getProfessionTotal();
            if (StringUtils.isNotBlank(numV) && !"—".equals(numV)) {
                map.replace(infoVO.getArea(), map.get(infoVO.getArea()) + Integer.valueOf(numV));
            }
        }
        return Result.ok(map);
    }


    @ApiOperation(value = "获取左侧按钮数据 ", notes = "获取左侧按钮数据")
    @GetMapping(value = "/queryButtonData")
    public Result<?> queryButtonData(
                    @ApiParam(value = "省份 全部变化")
                    @RequestParam(required = false) String province,
                                     @RequestParam String mainType,
                                     @ApiParam(value = " 类别  1 本科 2 高职 3 中职 4 研究院 5 园区基地  6 生产基地(当 加入搜索条件指明 当前搜索的范围 只变化当前的)")
                                     @RequestParam(required = false) String type,
                                     @RequestParam(required = false) String search) {
        Map<String, Integer> map = new HashMap<>();
        int benke = 0;
        int gaozhi = 0;
        int zhongzhi = 0;
        int yanjiuyuan = 0;
        int yuanqujidi = 0;
        int shengchanjidi = 0;
        if (StringUtils.isNotBlank(search)){
            String school985 = "";
            String school211 = "";
            List<String> professionList = null;
            if (search.indexOf("985")!=-1){
                school985 = "985";
                if (search.length()>4){
                    search = search.replace("985,","");
                } else {
                    search = search.replace("985","");
                }
            }
            if (search.indexOf("211")!=-1){
                school211 = "211";
                if (search.length()>4){
                    search = search.replace("211,","");
                } else {
                    search = search.replace("211","");
                }
            }
            if (search.length()>0){
                professionList = Arrays.asList(search.split(","));
            }
            //院校
            if (StringUtils.isNotBlank(type)){
                if ("1".equals(type)){
                    benke =  eduInfoService.countBySearch("1",professionList,school211,school985,mainType,province);
                    gaozhi =  eduInfoService.countBySearch("2",null,school211,school985,mainType,province);
                    zhongzhi =  eduInfoService.countBySearch("3",null,school211,school985,mainType,province);
                } else if ("2".equals(type)){
                    benke =  eduInfoService.countBySearch("1",null,school211,school985,mainType,province);
                    gaozhi =  eduInfoService.countBySearch("2",professionList,school211,school985,mainType,province);
                    zhongzhi =  eduInfoService.countBySearch("3",null,school211,school985,mainType,province);
                } else if ("3".equals(type)){
                    benke =  eduInfoService.countBySearch("1",null,school211,school985,mainType,province);
                    gaozhi =  eduInfoService.countBySearch("2",null,school211,school985,mainType,province);
                    zhongzhi =  eduInfoService.countBySearch("3",professionList,school211,school985,mainType,province);
                }
            } else {
                LambdaQueryWrapper<EduStation> bkqw = new LambdaQueryWrapper<>();
                LambdaQueryWrapper<EduStation> gzqw = new LambdaQueryWrapper<>();
                LambdaQueryWrapper<EduStation> zzqw = new LambdaQueryWrapper<>();
                bkqw.eq(EduStation::getMainType,mainType);
                gzqw.eq(EduStation::getMainType,mainType);
                zzqw.eq(EduStation::getMainType,mainType);
                bkqw.eq(EduStation::getType, "1");
                gzqw.eq(EduStation::getType, "2");
                zzqw.eq(EduStation::getType, "3");
                if (StringUtils.isNotBlank(province)){
                    bkqw.like(EduStation::getProvince, province);
                    gzqw.like(EduStation::getProvince, province);
                    zzqw.like(EduStation::getProvince, province);
                }
                benke = eduStationService.count(bkqw);
                gaozhi = eduStationService.count(gzqw);
                zhongzhi = eduStationService.count(zzqw);
            }

            //非院校
            LambdaQueryWrapper<Institute> insqw = new LambdaQueryWrapper<>();
            LambdaQueryWrapper<BasePark> parkqw = new LambdaQueryWrapper<>();
            LambdaQueryWrapper<BaseProduct> productqw = new LambdaQueryWrapper<>();
            insqw.eq(Institute::getMainType,mainType);
            parkqw.eq(BasePark::getMainType,mainType);
            productqw.eq(BaseProduct::getMainType,mainType);
            if (professionList != null){
                if ("4".equals(type)){
                    insqw.in(Institute::getType,professionList);
                }
                if ("5".equals(type)){
                    parkqw.in(BasePark::getType,professionList);
                }
                if ("6".equals(type)){
                    productqw.in(BaseProduct::getType,professionList);
                }
            }
            if (StringUtils.isNotBlank(province)) {

                insqw.like(Institute::getProvince, province);
                parkqw.like(BasePark::getProvince, province);
                productqw.like(BaseProduct::getProvince, province);
            }
            yanjiuyuan = instituteService.count(insqw);
            yuanqujidi = baseParkService.count(parkqw);
            shengchanjidi = baseProductService.count(productqw);


        } else {
            if (StringUtils.isBlank(province)) {
                benke = eduStationService.count(new LambdaQueryWrapper<EduStation>().eq(EduStation::getMainType,mainType).eq(EduStation::getType, "1"));
                yanjiuyuan = instituteService.count(new LambdaQueryWrapper<Institute>().eq(Institute::getMainType,mainType));
                yuanqujidi = baseParkService.count(new LambdaQueryWrapper<BasePark>().eq(BasePark::getMainType,mainType));
                shengchanjidi = baseProductService.count(new LambdaQueryWrapper<BaseProduct>().eq(BaseProduct::getMainType,mainType));
                gaozhi = eduStationService.count(new LambdaQueryWrapper<EduStation>().eq(EduStation::getMainType,mainType).eq(EduStation::getType, "2"));
                zhongzhi = eduStationService.count(new LambdaQueryWrapper<EduStation>().eq(EduStation::getMainType,mainType).eq(EduStation::getType, "3"));
            } else {
                benke = eduStationService.count(new LambdaQueryWrapper<EduStation>().eq(EduStation::getMainType,mainType).eq(EduStation::getType, "1").like(EduStation::getProvince, province));
                gaozhi = eduStationService.count(new LambdaQueryWrapper<EduStation>().eq(EduStation::getMainType,mainType).eq(EduStation::getType, "2").like(EduStation::getProvince, province));
                zhongzhi = eduStationService.count(new LambdaQueryWrapper<EduStation>().eq(EduStation::getMainType,mainType).eq(EduStation::getType, "3").like(EduStation::getProvince, province));
                yanjiuyuan = instituteService.count(new LambdaQueryWrapper<Institute>().eq(Institute::getMainType,mainType).like(Institute::getProvince, province));
                yuanqujidi = baseParkService.count(new LambdaQueryWrapper<BasePark>().eq(BasePark::getMainType,mainType).like(BasePark::getProvince, province));
                shengchanjidi = baseProductService.count(new LambdaQueryWrapper<BaseProduct>().eq(BaseProduct::getMainType,mainType).like(BaseProduct::getProvince, province));
            }
        }
        map.put("gaozhi", gaozhi);
        map.put("zhongzhi", zhongzhi);
        map.put("benke", benke);
        map.put("yanjiuyuan", yanjiuyuan);
        map.put("yuanqujidi", yuanqujidi);
        map.put("shengchanjidi", shengchanjidi);
        return Result.ok(map);
    }

    //@ApiOperation(value = "获取首页 上方全局模糊 搜索企业 ", notes = "获取首页 上方全局模糊 搜索企业")
    @GetMapping(value = "/queryHomeSearch2")
    public Result<List<SeachBO>> queryHomeSearch2 (
            @ApiParam(value = "1 院校 2 研究院 3 园区  4 生产基地",required = true)
            @RequestParam(required = false) String serchType,@RequestParam(required = false) String search) {
        Result<List<SeachBO>> result = new Result<>();
        if (StringUtils.isBlank(search)){
            return result.error500("搜索内容为空");
        } else {
            if (search.indexOf("省")!=-1||search.indexOf("市")!=-1||search.indexOf("自治区")!=-1){
                if (search.indexOf("内蒙古")!=-1){
                    search = "内蒙古";
                } else {
                    search = search.substring(0,2);
                }
            }
        }
        List<SeachBO> resList = new ArrayList<>();
        if ("1".equals(serchType)){
            LambdaQueryWrapper<EduStation> qw = new LambdaQueryWrapper();
            if (search.indexOf("机械")!=-1){
                qw.eq(EduStation::getMainType,"1");
            } else if (search.indexOf("数字")!=-1){
                qw.eq(EduStation::getMainType,"2");
            } else if (search.indexOf("文化")!=-1){
                qw.eq(EduStation::getMainType,"3");
            } else if (search.indexOf("氟化工")!=-1){
                qw.eq(EduStation::getMainType,"4");
            } else {
                qw.like(EduStation::getProvince,search);
            }
            List<EduStation> list = eduStationService.list(qw);
            for (EduStation station : list) {
                SeachBO seachBO = new SeachBO();
                seachBO.setId(station.getId());
                seachBO.setName(station.getSchoolName());
                String mainType = "";
                switch (station.getMainType()){
                    case "1":
                        mainType = "机械装备";
                        break;
                    case "2":
                        mainType = "数字产业";
                        break;
                    case "3":
                        mainType = "文化旅游产业";
                        break;
                    case "4":
                        mainType = "氟化工";
                        break;
                }
                //1 机械装备  2 数字产业 3 文化旅游产业 4氟化工
                seachBO.setMainType(mainType);
                String type = "";
                switch (station.getType()){
                    case "1":
                        type = "本科";
                        break;
                    case "2":
                        type = "高职";
                        break;
                    case "3":
                        type = "中职";
                        break;
                }
                //类别  类别  1 本科 2 高职 3 中职
                seachBO.setType(type);
                String area = station.getProvince();
                if (StringUtils.isNotBlank(station.getCity())) {
                    area += "-" + station.getCity();
                }
                seachBO.setArea(area);
                resList.add(seachBO);
            }
            result.setResult(resList);
        } else if ("2".equals(serchType)){
            LambdaQueryWrapper<Institute> qw = new LambdaQueryWrapper();
            if (search.indexOf("机械")!=-1){
                qw.eq(Institute::getMainType,"1");
            } else if (search.indexOf("数字")!=-1){
                qw.eq(Institute::getMainType,"2");
            } else if (search.indexOf("文化")!=-1){
                qw.eq(Institute::getMainType,"3");
            } else if (search.indexOf("氟化工")!=-1){
                qw.eq(Institute::getMainType,"4");
            } else {
                qw.like(Institute::getProvince,search);
            }
            List<Institute> list = instituteService.list(qw);
            SeachBO seachBO = new SeachBO();
            for (Institute institute:list){
                String mainType = "";
                switch (institute.getMainType()){
                    case "1":
                        mainType = "机械装备";
                        break;
                    case "2":
                        mainType = "数字产业";
                        break;
                    case "3":
                        mainType = "文化旅游产业";
                        break;
                    case "4":
                        mainType = "氟化工";
                        break;
                }
                seachBO.setArea(institute.getProvince());
                seachBO.setName(institute.getInstituteName());
                seachBO.setMainType(mainType);
                seachBO.setType(institute.getType());
                resList.add(seachBO);
            }
        } else if ("3".equals(serchType)){
            LambdaQueryWrapper<BasePark> qw = new LambdaQueryWrapper();
            if (search.indexOf("机械")!=-1){
                qw.eq(BasePark::getMainType,"1");
            } else if (search.indexOf("数字")!=-1){
                qw.eq(BasePark::getMainType,"2");
            } else if (search.indexOf("文化")!=-1){
                qw.eq(BasePark::getMainType,"3");
            } else if (search.indexOf("氟化工")!=-1){
                qw.eq(BasePark::getMainType,"4");
            } else {
                qw.like(BasePark::getProvince,search);
            }
            List<BasePark> list = baseParkService.list(qw);
            SeachBO seachBO = new SeachBO();
            for (BasePark park:list){
                String mainType = "";
                switch (park.getMainType()){
                    case "1":
                        mainType = "机械装备";
                        break;
                    case "2":
                        mainType = "数字产业";
                        break;
                    case "3":
                        mainType = "文化旅游产业";
                        break;
                    case "4":
                        mainType = "氟化工";
                        break;
                }
                seachBO.setArea(park.getProvince());
                seachBO.setName(park.getParkName());
                seachBO.setMainType(mainType);
                seachBO.setType(park.getType());
                resList.add(seachBO);
            }
        } else if ("4".equals(serchType)){
            LambdaQueryWrapper<BaseProduct> qw = new LambdaQueryWrapper();
                if (search.indexOf("机械")!=-1){
                    qw.eq(BaseProduct::getMainType,"1");
                } else if (search.indexOf("数字")!=-1){
                    qw.eq(BaseProduct::getMainType,"2");
                } else if (search.indexOf("文化")!=-1){
                    qw.eq(BaseProduct::getMainType,"3");
                } else if (search.indexOf("氟化工")!=-1){
                    qw.eq(BaseProduct::getMainType,"4");
                } else {
                    qw.like(BaseProduct::getProvince,search);
                }
            List<BaseProduct> list = baseProductService.list(qw);
            SeachBO seachBO = new SeachBO();
            for (BaseProduct product:list){
                String mainType = "";
                switch (product.getMainType()){
                    case "1":
                        mainType = "机械装备";
                        break;
                    case "2":
                        mainType = "数字产业";
                        break;
                    case "3":
                        mainType = "文化旅游产业";
                        break;
                    case "4":
                        mainType = "氟化工";
                        break;
                }
                seachBO.setArea(product.getProvince());
                seachBO.setName(product.getName());
                seachBO.setMainType(mainType);
                seachBO.setType(product.getType());
                resList.add(seachBO);
            }
        }
        return result;
    }

    @ApiOperation(value = "获取首页 上方全局模糊 搜索 ", notes = "获取首页 上方全局模糊 搜索")
    @GetMapping(value = "/queryHomeSearch")
    public Result<HomeSearchBO> queryHomeSearch(){
        Result<HomeSearchBO> result = new Result<>();
        HomeSearchBO homeSearchBO = new HomeSearchBO();
        List<Institute> instituteList = instituteService.list();
        List<EduStation> eduStationList = eduStationService.list();
        List<BasePark> parkList = baseParkService.list();
        List<BaseProduct> productList = baseProductService.list();
        List<SeachBO> instituteList1 = new ArrayList<>();
        List<SeachBO> eduStationList1 = new ArrayList<>();
        List<SeachBO> parkList1 = new ArrayList<>();
        List<SeachBO> productList1 = new ArrayList<>();
        for (EduStation station : eduStationList) {
            SeachBO seachBO = new SeachBO();
            seachBO.setId(station.getId());
            seachBO.setName(station.getSchoolName());
            String mainType = "";
            switch (station.getMainType()){
                case "1":
                    mainType = "机械装备";
                    break;
                case "2":
                    mainType = "数字产业";
                    break;
                case "3":
                    mainType = "文化旅游产业";
                    break;
                case "4":
                    mainType = "氟化工";
                    break;
            }
            //1 机械装备  2 数字产业 3 文化旅游产业 4氟化工
            seachBO.setMainType(mainType);
            String type = "";
            switch (station.getType()){
                case "1":
                    type = "本科";
                    break;
                case "2":
                    type = "高职";
                    break;
                case "3":
                    type = "中职";
                    break;
            }
            //类别  类别  1 本科 2 高职 3 中职
            seachBO.setType(type);
            String area = station.getProvince();
            if (StringUtils.isNotBlank(station.getCity())) {
                area += "-" + station.getCity();
            }
            seachBO.setArea(area);
            seachBO.setId(station.getId());
            eduStationList1.add(seachBO);
        }
        for (Institute institute:instituteList){
            SeachBO seachBO = new SeachBO();
            String mainType = "";
            switch (institute.getMainType()){
                case "1":
                    mainType = "机械装备";
                    break;
                case "2":
                    mainType = "数字产业";
                    break;
                case "3":
                    mainType = "文化旅游产业";
                    break;
                case "4":
                    mainType = "氟化工";
                    break;
            }
            seachBO.setArea(institute.getProvince());
            seachBO.setName(institute.getInstituteName());
            seachBO.setMainType(mainType);
            seachBO.setType(institute.getType());
            seachBO.setId(institute.getId());
            instituteList1.add(seachBO);
        }
        for (BasePark park:parkList){
            SeachBO seachBO = new SeachBO();
            String mainType = "";
            switch (park.getMainType()){
                case "1":
                    mainType = "机械装备";
                    break;
                case "2":
                    mainType = "数字产业";
                    break;
                case "3":
                    mainType = "文化旅游产业";
                    break;
                case "4":
                    mainType = "氟化工";
                    break;
            }
            seachBO.setArea(park.getProvince());
            seachBO.setName(park.getParkName());
            seachBO.setMainType(mainType);
            seachBO.setType(park.getType());
            seachBO.setId(park.getId());
            parkList1.add(seachBO);
        }
        for (BaseProduct product:productList){
            SeachBO seachBO = new SeachBO();
            String mainType = "";
            switch (product.getMainType()){
                case "1":
                    mainType = "机械装备";
                    break;
                case "2":
                    mainType = "数字产业";
                    break;
                case "3":
                    mainType = "文化旅游产业";
                    break;
                case "4":
                    mainType = "氟化工";
                    break;
            }
            seachBO.setArea(product.getProvince());
            seachBO.setName(product.getName());
            seachBO.setMainType(mainType);
            seachBO.setType(product.getType());
            seachBO.setId(product.getId());
            productList1.add(seachBO);
        }
        homeSearchBO.setEduStationList(eduStationList1);
        homeSearchBO.setInstituteList(instituteList1);
        homeSearchBO.setParkList(parkList1);
        homeSearchBO.setProductList(productList1);
        result.setResult(homeSearchBO);
        return result;
    }

    @ApiOperation(value = "获取首页 上方全局模糊 搜索  查看详情", notes = "获取首页 上方全局模糊 搜索 查看详情")
    @GetMapping(value = "/queryHomeSearchInfo")
    public Result<?> queryHomeSearchInfo(@RequestParam(name="id",required=true) String id,
                                         @ApiParam(value = "1 院校 2 研究院 3 园区  4 生产基地",required = true)
                            @RequestParam(required = false) String searchType){
        if (StringUtils.isBlank(searchType)){
            searchType = "1";
        }
        switch (searchType){
            case "1":
                EduStation eduStation = eduStationService.getById(id);
                if (ObjectUtil.isNotEmpty(eduStation)){
                    Result<EduInfoBO> res =  querySchoolById(id,eduStation.getMainType());
                    if (res.getCode() == 200){
                        EduInfoBO infoBO = res.getResult();
                        Map<String,Object> map = new HashMap<>();
                        String area = "";
                        String name = "";
                        String studentNum = "";
                        String contactWay = "";
                        String type = "";
                        String schoolNature = "";
                        List<EduInfoCollegeBO> professionNumList = new ArrayList<>();
                        if (ObjectUtil.isNotEmpty(infoBO)){
                            area = infoBO.getArea();
                            name = StringUtils.isBlank(infoBO.getSchoolName())?"":infoBO.getSchoolName();
                            studentNum = StringUtils.isBlank(infoBO.getStudentNum())?"0":infoBO.getStudentNum();
                            contactWay = StringUtils.isBlank(infoBO.getContactWay())?"":infoBO.getContactWay();
                            type = infoBO.getType();
                            schoolNature = infoBO.getSchoolNature();
                            professionNumList = infoBO.getProfessionNumList();
                        }
                        map.put("area",area);
                        map.put("name",name);
                        map.put("studentNum",studentNum);
                        map.put("contactWay",contactWay);
                        map.put("type",type);
                        map.put("schoolNature",schoolNature);
                        map.put("professionNumList",professionNumList);
                        return Result.ok(map);
                    }
                }
                break;
            case "2":
                Institute institute = instituteService.getById(id);
                if (ObjectUtil.isNotEmpty(institute)){
                    SeachBO seachBO = new SeachBO();
                    seachBO.setName(institute.getInstituteName());
                    String mainType = "";
                    switch (institute.getMainType()){
                        case "1":
                            mainType = "机械装备";
                            break;
                        case "2":
                            mainType = "数字产业";
                            break;
                        case "3":
                            mainType = "文化旅游产业";
                            break;
                        case "4":
                            mainType = "氟化工";
                            break;
                    }
                    seachBO.setMainType(mainType);
                    seachBO.setType(institute.getType());
                    seachBO.setId(institute.getId());
                    seachBO.setArea(institute.getProvince()+institute.getCity());
                    return Result.ok(seachBO);
                }
                break;
            case "3":
                BasePark park = baseParkService.getById(id);
                if (ObjectUtil.isNotEmpty(park)){
                    SeachBO seachBO = new SeachBO();
                    seachBO.setName(park.getParkName());
                    String mainType = "";
                    switch (park.getMainType()){
                        case "1":
                            mainType = "机械装备";
                            break;
                        case "2":
                            mainType = "数字产业";
                            break;
                        case "3":
                            mainType = "文化旅游产业";
                            break;
                        case "4":
                            mainType = "氟化工";
                            break;
                    }
                    seachBO.setMainType(mainType);
                    seachBO.setType(park.getType());
                    seachBO.setId(park.getId());
                    seachBO.setArea(park.getProvince()+park.getCity());
                    return Result.ok(seachBO);
                }
                break;
            case "4":
                BaseProduct product = baseProductService.getById(id);
                if (ObjectUtil.isNotEmpty(product)){
                    SeachBO seachBO = new SeachBO();
                    seachBO.setName(product.getName());
                    String mainType = "";
                    switch (product.getMainType()){
                        case "1":
                            mainType = "机械装备";
                            break;
                        case "2":
                            mainType = "数字产业";
                            break;
                        case "3":
                            mainType = "文化旅游产业";
                            break;
                        case "4":
                            mainType = "氟化工";
                            break;
                    }
                    seachBO.setMainType(mainType);
                    seachBO.setType(product.getType());
                    seachBO.setId(product.getId());
                    seachBO.setArea(product.getProvince()+product.getCity());
                    seachBO.setContent(product.getBaseContent());
                    return Result.ok(seachBO);
                }
                break;
        }
        return Result.error("无相关数据");
    }

    @ApiOperation(value = "后台-人才管理-学校-分页列表查询", notes = "后台-人才管理-学校-分页列表查询")
    @GetMapping(value = "/queryBackStageSchoolPageList")
    public Result<IPage<BackStageEduBO>> queryBackStageSchoolPageList(EduStationDTO dto,
                                                                      @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
                                                                      @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
                                                                      HttpServletRequest req) {
        Result<IPage<BackStageEduBO>> result = new Result<>();
//        LambdaQueryWrapper<EduStation> qw = new LambdaQueryWrapper<>();
//        Page<EduStation> page = new Page<EduStation>(pageNo, pageSize);
//        if (StringUtils.isNotBlank(dto.getSchoolName())){
//            qw.like(EduStation::getSchoolName,dto.getSchoolName());
//        }
//        if (StringUtils.isNotBlank(dto.getCity())){
//            qw.like(EduStation::getCity,dto.getCity());
//        }
//        if (StringUtils.isNotBlank(dto.getProvince())){
//            qw.like(EduStation::getProvince,dto.getProvince());
//        }
//        if (StringUtils.isNotBlank(dto.getContactWay())){
//            qw.like(EduStation::getContactWay,dto.getContactWay());
//        }
//        if (StringUtils.isNotBlank(dto.getType())){
//            qw.eq(EduStation::getType, dto.getType());
//        }
//        if (StringUtils.isNotBlank(dto.getProfession())){
//
//        }
//        IPage<EduStation> pageList = eduStationService.page(page, qw);
        IPage<BackStageEduBO> page = new Page<>(pageNo, pageSize);
        EduStationVO eduStationVO = new EduStationVO();
        BeanUtils.copyProperties(dto, eduStationVO);
        List<BackStageEduBO> resList = eduStationService.queryBackStagePage(eduStationVO);
        page.setTotal(resList.size());
        resList = resList.stream().skip((pageNo - 1) * pageSize).limit(pageSize).collect(Collectors.toList());
        page.setRecords(resList);
        result.setResult(page);
        return result;
    }

    @ApiOperation(value = "后台-人才管理-单独导入", notes = "后台-人才管理-单独导入")
    @PostMapping(value = "/importAlone")
    public Result<?> importAlone(@RequestBody ImportXlsDTO dto) {
        EduStation station = new EduStation();
        station.setId(UUIDGenerator.generate());
        station.setSchoolName(dto.getSchoolName());
        station.setContactWay(dto.getContactWay());
        station.setStudentNum(dto.getStudentNum());
        station.setType(dto.getType());
        String area = dto.getArea();
        if (StringUtils.isNotBlank(area) && area.indexOf("省") != -1) {
            area = area.replace("省", ",");
            List<String> pc = Arrays.asList(area.split(","));
            if (pc.size() == 1) {
                station.setProvince(pc.get(0));
            } else if (pc.size() == 2) {
                station.setProvince(pc.get(0));
                station.setCity(pc.get(1));
            }
        }
        EduStation old = eduStationService.getOne(new LambdaQueryWrapper<EduStation>().eq(EduStation::getMainType,dto.getMainType()).eq(EduStation::getSchoolName, station.getSchoolName()).eq(EduStation::getProvince, station.getProvince()));
        if (ObjectUtil.isNotEmpty(old)) {
            return Result.error("该学校已经导入");
        }
//        eduStationService.save(station);
        return Result.ok("导入成功");
    }

    //    @ApiOperation(value="后台-人才管理-导出", notes="后台-人才管理-导出")
    @RequestMapping(value = "/exportXls")
    public ModelAndView exportXls(HttpServletRequest request, @RequestParam String mainType) {
        String selections = request.getParameter("selections");
        EduStationVO eduStationVO = new EduStationVO();
        eduStationVO.setMainType(mainType);
        List<BackStageEduBO> resList = eduStationService.queryBackStagePage(eduStationVO);
        List<BackStageEduBO> exportList = null;
        if (oConvertUtils.isNotEmpty(selections)) {
            List<String> selectionList = Arrays.asList(selections.split(","));
            try {
                exportList = resList.stream().filter(item -> selectionList.contains(item.getId())).collect(Collectors.toList());
            } catch (Exception e) {
                throw new JeecgBootException("导出异常");
            }
        }
        LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
        ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
        mv.addObject(NormalExcelConstants.FILE_NAME, "人才导出"); //此处设置的filename无效 ,前端会重更新设置一下
        mv.addObject(NormalExcelConstants.CLASS, BackStageEduBO.class);
        mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("机械装备产业院校" + "报表", "导出人:" + sysUser.getRealname(), DateUtils.date_sdf_wz.format(DateUtil.date())));
        mv.addObject(NormalExcelConstants.DATA_LIST, exportList);
        return mv;
    }


    @ApiOperation(value = "后台-人才管理-导出模板", notes = "后台-人才管理-导出模板")
    @GetMapping(value = "/exportTmpXls")
    public ModelAndView exportTmpXls(HttpServletResponse response, @RequestParam(required = false) String mainType) throws Exception {
        //LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
        ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
        List<ImportXlsDTO> exportList = new ArrayList<>();
        ImportXlsDTO test = new ImportXlsDTO();
        test.setSchoolName("福建师范大学");
        test.setArea("福建省福州");
        test.setType("本科、高职、中职");
        test.setStudentNum("10000");
        test.setContactWay("0591-12345678");
        mv.addObject(NormalExcelConstants.FILE_NAME, "人才模板导出"); //此处设置的filename无效 ,前端会重更新设置一下
        mv.addObject(NormalExcelConstants.CLASS, ImportXlsDTO.class);
        mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("机械装备产业院校模板" + "报表", "导出人:" + "admin", DateUtils.date_sdf_wz.format(DateUtil.date())));
        mv.addObject(NormalExcelConstants.DATA_LIST, exportList);
        return mv;
//        Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams("机械装备产业院校模板" + "报表", "导出人:" + "admin", DateUtils.date_sdf_wz.format(DateUtil.date())), ImportXlsDTO.class, exportList);
//        response.setHeader("content-disposition", "attachment;filename=" + "demo.xls");
//        ServletOutputStream out = response.getOutputStream();
//        workbook.write(out);
//        out.flush();

    }


    @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
    public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response,@RequestParam String mainType) {
        MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
        Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
        for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
            MultipartFile file = entity.getValue();// 获取上传文件对象
            ImportParams params = new ImportParams();
            params.setTitleRows(2);
            params.setHeadRows(1);
            params.setNeedSave(true);
            try {
                List<ImportXlsDTO> list = ExcelImportUtil.importExcel(file.getInputStream(), ImportXlsDTO.class, params);
                //update-begin-author:taoyan date:20190528 for:批量插入数据
                long start = System.currentTimeMillis();
                List<EduStation> stationListForAdd = new ArrayList<>();
                for (ImportXlsDTO dto : list) {
                    EduStation station = new EduStation();
                    station.setId(UUIDGenerator.generate());
                    station.setSchoolName(dto.getSchoolName());
                    station.setMainType(mainType);
                    station.setContactWay(dto.getContactWay());
                    station.setStudentNum(dto.getStudentNum());
                    station.setType(dto.getType());
                    String area = dto.getArea();
                    if (StringUtils.isNotBlank(area) && area.indexOf("省") != -1) {
                        area = area.replace("省", ",");
                        List<String> pc = Arrays.asList(area.split(","));
                        if (pc.size() == 1) {
                            station.setProvince(pc.get(0));
                        } else if (pc.size() == 2) {
                            station.setProvince(pc.get(0));
                            station.setCity(pc.get(1));
                        }
                    }
                    EduStation old = eduStationService.getOne(new LambdaQueryWrapper<EduStation>().eq(EduStation::getMainType,mainType).eq(EduStation::getSchoolName, station.getSchoolName()).eq(EduStation::getProvince, station.getProvince()));
                    if (ObjectUtil.isNotEmpty(old)) {
                        return Result.error("该学校已经导入");
                    }
                    stationListForAdd.add(station);

                }
                eduStationService.saveBatch(stationListForAdd);
                //400条 saveBatch消耗时间1592毫秒  循环插入消耗时间1947毫秒
                //1200条  saveBatch消耗时间3687毫秒 循环插入消耗时间5212毫秒
                log.info("消耗时间" + (System.currentTimeMillis() - start) + "毫秒");
                //update-end-author:taoyan date:20190528 for:批量插入数据
                return Result.ok("文件导入成功！数据行数：" + stationListForAdd.size());
            } catch (Exception e) {
                log.error(e.getMessage(), e);
                return Result.error("文件导入失败:" + e.getMessage());
            } finally {
                try {
                    file.getInputStream().close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
        return Result.error("文件导入失败！");
    }


    @ApiOperation(value = "各省排名前三及统计-分页列表查询", notes = "各省排名前三及统计-分页列表查询")
    @GetMapping(value = "/querySummaryPageList")
    public Result<?> querySummaryPageList(EduSummary eduSummary,
                                          @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
                                          @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
                                          HttpServletRequest req) {
        LambdaQueryWrapper<EduSummary> qw = new LambdaQueryWrapper<>();
        qw.eq(EduSummary::getMainType,eduSummary.getMainType());
        if (StringUtils.isNotBlank(eduSummary.getProvince())){
            qw.like(EduSummary::getProvince,eduSummary.getProvince());
        }
        if (StringUtils.isNotBlank(eduSummary.getSchoolName())){
            qw.like(EduSummary::getSchoolName,eduSummary.getSchoolName());
        }
        Page<EduSummary> page = new Page<EduSummary>(pageNo, pageSize);
        IPage<EduSummary> pageList = eduSummaryService.page(page, qw);
        return Result.ok(pageList);
    }



    @ApiOperation(value = "人才2.0列表类-筛选", notes = "人才2.0列表类")
    @GetMapping(value = "/queryProvinceSchoolPage")
    public Result<ProvinceSchoolBO> queryProvinceSchoolPage(
            @ApiParam(value = "1 机械装备  2 数字产业 3 文化旅游产业 4氟化工",required = true)
            @RequestParam(required = true) String maintype,
            @ApiParam(value = "省份")
            @RequestParam(required = false) String province,
            @ApiParam(value = "类别  类别  1 本科 2 高职 3 中职 4 研究院 5 园区基地  6 生产基地",required = true)
            @RequestParam(required = false) String type,
            @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
            @RequestParam(name = "pageSize", defaultValue = "8") Integer pageSize
    ){
        Result<ProvinceSchoolBO> result = new Result<>();
        pageSize = pageSize == null? 8:pageSize;
        List<String> pronvinceList = new ArrayList<>();
        if ("1".equals(type)||"2".equals(type)||"3".equals(type)){
            pronvinceList = eduStationService.queryProvinceList(maintype,type);
        } else if ("4".equals(type)){
            pronvinceList = instituteService.queryProvinceList(maintype,type);
        } else if ("4".equals(type)){
            pronvinceList = baseParkService.queryProvinceList(maintype,type);
        } else if ("4".equals(type)){
            pronvinceList = baseProductService.queryProvinceList(maintype,type);
        }
        Page<ProvinceDataBO> page = new Page<ProvinceDataBO>(pageNo, pageSize);
        if (StringUtils.isNotBlank(province)){
            if (pronvinceList.contains(province)){
                page.setTotal(1);
                pronvinceList = new ArrayList<>();
                pronvinceList.add(province);
            } else {
                page.setTotal(0);
            }
        } else {
            if ((pronvinceList.size()%pageSize)==0){
                page.setTotal(pronvinceList.size()/pageSize);
            } else {
                page.setTotal(pronvinceList.size()/pageSize+1);
            }

        }
        pronvinceList = pronvinceList.stream().skip((pageNo-1)*pageSize).limit(pageSize).collect(Collectors.toList());
        ProvinceSchoolBO provinceSchoolBO = new ProvinceSchoolBO();
        List<ProvinceDataBO> resList = new ArrayList<>();
        int schoolNum = 0;
        if ("1".equals(type)||"2".equals(type)||"3".equals(type)){
            LambdaQueryWrapper<EduStation> qw = new LambdaQueryWrapper<>();
            qw.eq(EduStation::getMainType,maintype);
            if (StringUtils.isNotBlank(province)){
                qw.like(EduStation::getProvince,province);
            }
            if (StringUtils.isNotBlank(type)){
                qw.like(EduStation::getType,type);
            }
            if (pronvinceList.size()>0){
                qw.in(EduStation::getProvince,pronvinceList);
            }
            List<EduStation> stationList = eduStationService.list(qw);
            for (EduStation station:stationList){
                if (StringUtils.isNotBlank(province)){
                    if (!province.equals(station.getProvince())){
                        continue;
                    }
                } else {
                    if (!pronvinceList.contains(station.getProvince())){
                        continue;
                    }
                }
                schoolNum++;
                ProvinceDataBO resCur = null;
                for (ProvinceDataBO res:resList){
                    if (res.getProvince().equals(station.getProvince())){
                        resCur =res;
                    }
                }
                if (ObjectUtil.isEmpty(resCur)) {
                    ProvinceDataBO dataBO = new ProvinceDataBO();
                    dataBO.setProvince(station.getProvince());
                    dataBO.setStudentTotal("0");
                    resList.add(dataBO);
                    resCur = dataBO;
                }
                if (StringUtils.isNotBlank(station.getStudentNum())&&!"暂无数据".equals(station.getStudentNum())){
                    resCur.setStudentTotal(Integer.valueOf(resCur.getStudentTotal())+Integer.valueOf(station.getStudentNum())+"");
                }
                List<EduBO> eduList = resCur.getProvinceSchoolList();
                if (eduList == null){
                    eduList = new ArrayList<>();
                }
                EduBO eduBO = new EduBO();
                eduBO.setId(station.getId());
                eduBO.setContactWay(station.getContactWay());
                eduBO.setSchoolName(station.getSchoolName());
                eduBO.setTotal(station.getStudentNum());
                eduList.add(eduBO);
//                try {
//                    Result<EduInfoBO> res = querySchoolById(eduBO.getId(),maintype);
//                    if (res.getCode() == 200) {
//                        eduBO.setSchoolInfo(res.getResult());
//                    }
//                } catch (Exception e) {
//
//                }
                resCur.setSchoolTotal(eduList.size()+"");
                resCur.setProvinceSchoolList(eduList);
            }
        } else if ("4".equals(type)){
            LambdaQueryWrapper<Institute> qw = new LambdaQueryWrapper<>();
            qw.eq(Institute::getMainType,maintype);
            if (StringUtils.isNotBlank(province)){
                qw.like(Institute::getProvince,province);
            }
            if (pronvinceList.size()>0){
                qw.in(Institute::getProvince,pronvinceList);
            }
            List<Institute> stationList = instituteService.list(qw);
            for (Institute station:stationList) {
                if (StringUtils.isNotBlank(province)) {
                    if (!province.equals(station.getProvince())) {
                        continue;
                    }
                } else {
                    if (!pronvinceList.contains(station.getProvince())) {
                        continue;
                    }
                }
                schoolNum++;

                ProvinceDataBO resCur = null;
                for (ProvinceDataBO res:resList){
                    if (res.getProvince().equals(station.getProvince())){
                        resCur =res;
                    }
                }
                if (ObjectUtil.isEmpty(resCur)) {
                    ProvinceDataBO dataBO = new ProvinceDataBO();
                    dataBO.setProvince(station.getProvince());
                    dataBO.setStudentTotal("0");
                    resList.add(dataBO);
                    resCur = dataBO;
                }
                resCur.setStudentTotal(Integer.valueOf(resCur.getStudentTotal())+1+"");
                List<EduBO> eduList = resCur.getProvinceSchoolList();
                if (eduList == null){
                    eduList = new ArrayList<>();
                }
                EduBO eduBO = new EduBO();
                eduBO.setId(station.getId());
                eduBO.setSchoolName(station.getInstituteName());
                eduBO.setTotal("-");
                eduList.add(eduBO);
                resCur.setSchoolTotal(eduList.size()+"");
                resCur.setProvinceSchoolList(eduList);
            }
        }  else if ("5".equals(type)){
            LambdaQueryWrapper<BasePark> qw = new LambdaQueryWrapper<>();
            qw.eq(BasePark::getMainType,maintype);
            if (StringUtils.isNotBlank(province)){
                qw.like(BasePark::getProvince,province);
            }
            if (pronvinceList.size()>0){
                qw.in(BasePark::getProvince,pronvinceList);
            }
            List<BasePark> stationList = baseParkService.list(qw);
            for (BasePark station:stationList) {
                if (StringUtils.isNotBlank(province)) {
                    if (!province.equals(station.getProvince())) {
                        continue;
                    }
                } else {
                    if (!pronvinceList.contains(station.getProvince())) {
                        continue;
                    }
                }
                schoolNum++;

                ProvinceDataBO resCur = null;
                for (ProvinceDataBO res:resList){
                    if (res.getProvince().equals(station.getProvince())){
                        resCur =res;
                    }
                }
                if (ObjectUtil.isEmpty(resCur)) {
                    ProvinceDataBO dataBO = new ProvinceDataBO();
                    dataBO.setProvince(station.getProvince());
                    dataBO.setStudentTotal("0");
                    resList.add(dataBO);
                    resCur = dataBO;
                }
                resCur.setStudentTotal(Integer.valueOf(resCur.getStudentTotal())+1+"");
                List<EduBO> eduList = resCur.getProvinceSchoolList();
                if (eduList == null){
                    eduList = new ArrayList<>();
                }
                EduBO eduBO = new EduBO();
                eduBO.setId(station.getId());
                eduBO.setSchoolName(station.getParkName());
                eduBO.setTotal("-");
                eduList.add(eduBO);
                resCur.setSchoolTotal(eduList.size()+"");
                resCur.setProvinceSchoolList(eduList);
            }

        } else if ("6".equals(type)){
            LambdaQueryWrapper<BaseProduct> qw = new LambdaQueryWrapper<>();
            qw.eq(BaseProduct::getMainType,maintype);
            if (StringUtils.isNotBlank(province)){
                qw.like(BaseProduct::getProvince,province);
            }
            if (pronvinceList.size()>0){
                qw.in(BaseProduct::getProvince,pronvinceList);
            }
            List<BaseProduct> stationList = baseProductService.list(qw);
            for (BaseProduct station:stationList) {
                if (StringUtils.isNotBlank(province)) {
                    if (!province.equals(station.getProvince())) {
                        continue;
                    }
                } else {
                    if (!pronvinceList.contains(station.getProvince())) {
                        continue;
                    }
                }
                schoolNum++;

                ProvinceDataBO resCur = null;
                for (ProvinceDataBO res:resList){
                    if (res.getProvince().equals(station.getProvince())){
                        resCur =res;
                    }
                }
                if (ObjectUtil.isEmpty(resCur)) {
                    ProvinceDataBO dataBO = new ProvinceDataBO();
                    dataBO.setProvince(station.getProvince());
                    dataBO.setStudentTotal("0");
                    resList.add(dataBO);
                    resCur = dataBO;
                }
                resCur.setStudentTotal(Integer.valueOf(resCur.getStudentTotal())+1+"");
                List<EduBO> eduList = resCur.getProvinceSchoolList();
                if (eduList == null){
                    eduList = new ArrayList<>();
                }
                EduBO eduBO = new EduBO();
                eduBO.setId(station.getId());
                eduBO.setSchoolName(station.getName());
                eduBO.setTotal("-");
                eduList.add(eduBO);
                resCur.setSchoolTotal(eduList.size()+"");
                resCur.setProvinceSchoolList(eduList);
            }

        }

        page.setRecords(resList);
        int studentNumSum = 0;
        if ("1".equals(type)||"2".equals(type)||"3".equals(type)){
            for (ProvinceDataBO res:resList){
                studentNumSum += Integer.valueOf(res.getStudentTotal());
            }
        }
        provinceSchoolBO.setStudentTotal(studentNumSum+"");
        provinceSchoolBO.setSchoolTotal(schoolNum+"");
        provinceSchoolBO.setEduPageList(page);
        result.setResult(provinceSchoolBO);
        return result;
    }

    @ApiOperation(value = "人才2.0  列表类-右侧", notes = "人才2.0列表类")
    @PostMapping(value = "/querySchoolPage")
    public Result<EduMergeBO> querySchoolPage(@Valid @RequestBody HomeSearchDTO dto){
        Result<EduMergeBO> result = new Result<>();
        EduMergeBO mergeBO = new EduMergeBO();
        List<MergeBO> resList = new ArrayList<>();
        String title = "";
        String search = dto.getSearch();
        String searchtype = dto.getType();
        if ("1".equals(searchtype)||"2".equals(searchtype)||"3".equals(searchtype)){

            String professions = dto.getProfessions();
            List<String> professionList = null;
            if (StringUtils.isNotBlank(professions)){
                professionList = Arrays.asList(professions.split(","));
                mergeBO.setQueryParam2(professionList);
            } else {
                if (StringUtils.isNotBlank(search)){
                    int flag = 0;
                    if (search.indexOf("985")!=-1){
                        dto.setSchoolNature("985");
                        flag+=1;
                        if (search.length()>4){
                            search = search.replace("985,","");
                        } else {
                            search = search.replace("985","");
                        }
                    }
                    if (search.indexOf("211")!=-1){
                        dto.setSchoolNature("211");
                        flag+=1;
                        if (search.length()>4){
                            search = search.replace("211,","");
                        } else {
                            search = search.replace("211","");
                        }
                    }
                    if (flag==2){
                        dto.setSchoolNature("985,211");
                    }
                    if (search.length()>0){
                        professionList = Arrays.asList(search.split(","));
                        mergeBO.setQueryParam2(professionList);
                    }
                }
            }
            ProfessionVO professionVO = new ProfessionVO();
            if(StringUtils.isNotBlank(dto.getProvince())){
                professionVO.setProvince(dto.getProvince());
            }
            if(StringUtils.isNotBlank(dto.getType())){
                professionVO.setType(dto.getType());
            }
            professionVO.setProfessions(professionList);
//            professionVO.setSchoolNature(dto.getSchoolNature());
            if (StringUtils.isNotBlank(dto.getSchoolNature())) {
                List<String> natures = new ArrayList<>();
                int flag = 0;
                if (dto.getSchoolNature().indexOf("211")!=-1){
                    professionVO.setSchoolNature("211");
                    flag +=1;
                    natures.add("211");
                }
                if (dto.getSchoolNature().indexOf("985")!=-1){
                    professionVO.setSchoolNature("985");
                    flag +=1;
                    natures.add("985");
                }
                if (flag>1){
                    professionVO.setSchoolNature("211985");
                }
                mergeBO.setQueryParam1(natures);
            }
            if (StringUtils.isNotBlank(dto.getCity())){
                if (dto.getCity().endsWith("市")){
                    professionVO.setCity(dto.getCity().substring(0,dto.getCity().length()-1));
                } else {
                    professionVO.setCity(dto.getCity());
                }
            }
            professionVO.setMainType(dto.getMainType());
            List<FullInfoVO> queryRes = eduInfoService.queryFullInfoByProfession(professionVO);
            Set<String> schoolIds = new HashSet<>();

            for (FullInfoVO infoVO : queryRes) {
                if (StringUtils.isNotBlank(dto.getMainType()) && !dto.getMainType().equals(infoVO.getMainType())){
                    continue;
                }
                if (schoolIds.contains(infoVO.getId())){
                    continue;
                }
                MergeBO seachBO = new MergeBO();
                seachBO.setId(infoVO.getId());
                seachBO.setName(infoVO.getSchoolName());
                seachBO.setArea(infoVO.getArea());
                String type = "";
                switch (infoVO.getType()){
                    case "1":
                        type = "本科";
                        break;
                    case "2":
                        type = "高职";
                        break;
                    case "3":
                        type = "中职";
                        break;
                }
                seachBO.setType(type);
                String mainType = "";
                switch (infoVO.getMainType()){
                    case "1":
                        mainType = "机械装备";
                        break;
                    case "2":
                        mainType = "数字产业";
                        break;
                    case "3":
                        mainType = "文化旅游产业";
                        break;
                    case "4":
                        mainType = "氟化工";
                        break;
                }
                seachBO.setTotal(infoVO.getStudentTotal());
                seachBO.setMainType(mainType);
                resList.add(seachBO);
                schoolIds.add(infoVO.getId());
            }
            if (StringUtils.isNotBlank(dto.getType())){
                title += swithType(dto.getType());
            }
            title += "院校";
        } else if ("4".equals(searchtype)){
            LambdaQueryWrapper<Institute> qw = new LambdaQueryWrapper<>();
            if(StringUtils.isNotBlank(dto.getProfessions())){
                String professions = dto.getProfessions();
                List<String> professionList = Arrays.asList(professions.split(","));
                if (professionList.size() > 0) {
                    qw.in(Institute::getType,professionList);
                    mergeBO.setQueryParam2(professionList);
                }
            } else {
                if (StringUtils.isNotBlank(search)){
                    List<String> professionList = Arrays.asList(search.split(","));
                    if (professionList.size() > 0) {
                        qw.in(Institute::getType,professionList);
                        mergeBO.setQueryParam2(professionList);
                    }
                }
            }
            if (StringUtils.isNotBlank(dto.getMainType())){
                qw.eq(Institute::getMainType,dto.getMainType());
            }
            if (StringUtils.isNotBlank(dto.getProvince())){
                String province = dto.getProvince();
                if (province.endsWith("省")){
                    province = province.substring(0,province.length()-1);
                }
                if (province.indexOf("自治区")!=-1){
                    province = province.substring(0,2);
                }
                qw.like(Institute::getProvince,province);
            }
            if (StringUtils.isNotBlank(dto.getCity())){
                if (dto.getCity().endsWith("市")){
                    qw.like(Institute::getCity,dto.getCity().substring(0,dto.getCity().length()-1));
                } else {
                    qw.like(Institute::getCity,dto.getCity());
                }
            }
            List<Institute> instituteList = instituteService.list(qw);
            for (Institute institute:instituteList){
                MergeBO seachBO = new MergeBO();
                seachBO.setId(institute.getId());
                seachBO.setName(institute.getInstituteName());
                seachBO.setArea(institute.getProvince());
                seachBO.setType(institute.getType());
                String mainType = swithMainType(institute.getMainType());
                seachBO.setMainType(mainType);
                resList.add(seachBO);
            }
            title ="研究院";
        } else if ("5".equals(searchtype)){
            LambdaQueryWrapper<BasePark> qw = new LambdaQueryWrapper<>();
            if(StringUtils.isNotBlank(dto.getProfessions())){
                String professions = dto.getProfessions();
                List<String> professionList = Arrays.asList(professions.split(","));
                if (professionList.size() > 0) {
                    qw.in(BasePark::getType,professionList);
                    mergeBO.setQueryParam2(professionList);
                }
            } else {
                if (StringUtils.isNotBlank(search)){
                    List<String> professionList = Arrays.asList(search.split(","));
                    if (professionList.size() > 0) {
                        qw.in(BasePark::getType,professionList);
                        mergeBO.setQueryParam2(professionList);
                    }
                }
            }
            if (StringUtils.isNotBlank(dto.getMainType())){
                qw.eq(BasePark::getMainType,dto.getMainType());
            }
            if (StringUtils.isNotBlank(dto.getProvince())){
                String province = dto.getProvince();
                if (province.endsWith("省")){
                    province = province.substring(0,province.length()-1);
                }
                if (province.indexOf("自治区")!=-1){
                    province = province.substring(0,2);
                }
                qw.like(BasePark::getProvince,province);
            }
            if (StringUtils.isNotBlank(dto.getCity())){
                if (dto.getCity().endsWith("市")){
                    qw.like(BasePark::getCity,dto.getCity().substring(0,dto.getCity().length()-1));
                } else {
                    qw.like(BasePark::getCity,dto.getCity());
                }
            }
            List<BasePark> parkList = baseParkService.list(qw);
            for (BasePark park:parkList){
                MergeBO seachBO = new MergeBO();
                seachBO.setId(park.getId());
                seachBO.setName(park.getParkName());
                seachBO.setArea(park.getProvince());
                seachBO.setType(park.getType());
                String mainType = swithMainType(park.getMainType());
                seachBO.setMainType(mainType);
                resList.add(seachBO);
            }
            title ="园区";
        } else if ("6".equals(searchtype)){
            LambdaQueryWrapper<BaseProduct> qw = new LambdaQueryWrapper<>();
            if(StringUtils.isNotBlank(dto.getProfessions())){
                String professions = dto.getProfessions();
                List<String> professionList = Arrays.asList(professions.split(","));
                if (professionList.size() > 0) {
                    qw.in(BaseProduct::getType,professionList);
                    mergeBO.setQueryParam2(professionList);
                }
            } else {
                if (StringUtils.isNotBlank(search)){
                    List<String> professionList = Arrays.asList(search.split(","));
                    if (professionList.size() > 0) {
                        qw.in(BaseProduct::getType,professionList);
                        mergeBO.setQueryParam2(professionList);
                    }
                }
            }
            if (StringUtils.isNotBlank(dto.getMainType())){
                qw.eq(BaseProduct::getMainType,dto.getMainType());
            }
            if (StringUtils.isNotBlank(dto.getCity())){
                if (dto.getCity().endsWith("市")){
                    qw.like(BaseProduct::getCity,dto.getCity().substring(0,dto.getCity().length()-1));
                } else {
                    qw.like(BaseProduct::getCity,dto.getCity());
                }
            }
            if (StringUtils.isNotBlank(dto.getProvince())){
                String province = dto.getProvince();
                if (province.endsWith("省")||province.endsWith("市")){
                    province = province.substring(0,province.length()-1);
                }
                if (province.indexOf("自治区")!=-1){
                    province = province.substring(0,2);
                }
                qw.like(BaseProduct::getProvince,province);
            }
            List<BaseProduct> productList = baseProductService.list(qw);
            for (BaseProduct product:productList){
                MergeBO seachBO = new MergeBO();
                seachBO.setId(product.getId());
                seachBO.setName(product.getName());
                seachBO.setArea(product.getProvince());
                seachBO.setType(product.getType());
                String mainType = swithMainType(product.getMainType());
                seachBO.setMainType(mainType);
                resList.add(seachBO);
            }
            title ="生产基地";
        }
        int pageSize = dto.getPageSize()==null?10:dto.getPageSize();
        int pageNo = dto.getPageNo()==null?1:dto.getPageNo();
        int schoolTotal = resList.size();
        resList = resList.stream().sorted(new Comparator<MergeBO>() {
            @Override
            public int compare(MergeBO o1, MergeBO o2) {
                if (StringUtils.isBlank(o1.getTotal())||StringUtils.isBlank(o2.getTotal())){
                    return 0;
                } else {
                    return Integer.valueOf(o2.getTotal())- Integer.valueOf(o1.getTotal());
                }

            }
        }).skip(pageSize * (pageNo - 1)).limit(pageSize).collect(Collectors.toList());
        IPage<MergeBO> pageList = new Page<>();
        pageList.setRecords(resList);
        pageList.setTotal(schoolTotal);
        if (StringUtils.isNotBlank(dto.getMainType())){
            title = swithMainType(dto.getMainType())+title;
        }
        if (StringUtils.isNotBlank(dto.getProvince())){
            if (StringUtils.isNotBlank(dto.getCity())){
                title = dto.getProvince()+dto.getCity()+title;
            } else {
                title = dto.getProvince()+title;
            }
        } else {
            title = "全国"+title;
        }

        mergeBO.setTitle(title);
        mergeBO.setTotal(schoolTotal+"");
        mergeBO.setSeachPage(pageList);
        result.setResult(mergeBO);
        return result;
    }


    private String swithMainType(String mainType){
        String res = "";
        switch (mainType){
            case "1":
                res = "机械装备";
                break;
            case "2":
                res = "数字产业";
                break;
            case "3":
                res = "文化旅游产业";
                break;
            case "4":
                res = "氟化工";
                break;
        }
        return res;
    }

    private String swithType(String type){
        String res = "";
        switch (type){
            case "1":
                res = "本科";
                break;
            case "2":
                res = "高职";
                break;
            case "3":
                res = "中职";
                break;
        }
        return res;
    }

}
